import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sltchat/constant.dart';
import 'package:sltchat/routs.dart';

import 'message_logic.dart';

class MessagePage extends StatelessWidget {
  const MessagePage({super.key});
  @override
  Widget build(BuildContext context) {
    final logic = Get.find<MessageLogic>();

    return Scaffold(
        backgroundColor: Colors.white,
        body: Column(children: [
          Stack(
            children: [
              Container(
                  width: double.infinity,
                  padding: const EdgeInsets.symmetric(vertical: 20),
                  child: const Center(
                      child: Text("对话",
                          style: TextStyle(fontWeight: FontWeight.bold)))),
              Positioned.fill(
                child: Padding(
                  padding: const EdgeInsets.only(right: 10),
                  child: Align(
                      alignment: Alignment.centerRight,
                      child: InkWell(
                        onTap: () {},
                        child: const Padding(
                            padding: EdgeInsets.all(8.0),
                            child: Icon(Icons.search)),
                      )),
                ),
              )
            ],
          ),
          Expanded(
              child: ListView.builder(
            itemBuilder: (BuildContext context, int index) {
              return InkWell(
                onTap: () {
                  Get.toNamed(RoutePath.chat);
                },
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 10),
                  child: IntrinsicHeight(
                    child: Row(
                      children: [
                        const Padding(
                            padding: EdgeInsets.all(4),
                            child: CircleAvatar(radius: 30)),
                        const SizedBox(width: 15),
                        Expanded(
                          child: Column(
                            children: [
                              Expanded(
                                  child: Column(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      crossAxisAlignment:
                                          CrossAxisAlignment.start,
                                      children: [
                                    const Text("豆包，对方名字豆包，对方名字豆包，对方名字豆包，对方名字",
                                        maxLines: 1,
                                        overflow: TextOverflow.ellipsis,
                                        style: TextStyle(
                                            color: Colors.black,
                                            fontWeight: FontWeight.bold)),
                                    Text(
                                      "最近一条聊天记录最近一条聊天记录最近一条聊天记录",
                                      maxLines: 1,
                                      overflow: TextOverflow.ellipsis,
                                      style: TextStyle(
                                          fontSize: 13, color: color_999999),
                                    ),
                                  ])),
                              Divider(
                                  height: 0.1, color: Colors.grey.withAlpha(40))
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              );
            },
            itemCount: 10,
          ))
        ]));
  }
}
